import { _decorator, Component, Node, SkeletalAnimation, Vec3 } from 'cc';
import { PathMove } from '../PlayableFramework/Tools/Path/PathMove';
const { ccclass, property } = _decorator;

@ccclass('Actor')
export class Actor extends Component {

    public anim:SkeletalAnimation
    public mover:PathMove;

    protected onLoad(): void {
        this.anim = this.getComponentInChildren(SkeletalAnimation);
        this.mover = this.getComponent(PathMove);
        for (let i = 0; i < this.moneyStackNode.children.length; i++) {
            this.moneyStackNode.children[i].active = false;`1`
        }
    }
    
    start() {
        this.anim.play("idle");
    }

    update(deltaTime: number) {
        
    }


    public moneyProgress = 0;
    @property(Node)
    public moneyStackNode:Node;
    public fillMoney(){
        this.moneyProgress++;
        var count = Math.floor(this.moneyProgress / 5);
        for (let i = 0; i < this.moneyStackNode.children.length; i++) {
            this.moneyStackNode.children[i].active = i < count;
        }
    }
    
    public costMoney(){
        this.moneyProgress--;
        var count = Math.floor(this.moneyProgress / 5);
        for (let i = 0; i < this.moneyStackNode.children.length; i++) {
            this.moneyStackNode.children[i].active = i < count;
        }
    }
}


